#include "..\CookHeader.h"

int SIZE = 6;
Array <Array <string>> callQueue; // ť 2 迭 
int front = 0, rear = 0;

bool isQueueFull() {
	if ((rear + 1) % SIZE == front)
		return true;
	else
		return false;
}

bool isQueueEmpty() {
	if (front == rear)
		return true;
	else
		return false;
}

void enQueue(Array <string> data) {
	if (isQueueFull()) {
		println("ť  áϴ.");
		return;
	}
	rear = (rear + 1) % SIZE;
	callQueue[rear] = data;
}

Array <string> deQueue() {
	if (isQueueEmpty()) {
		println("ť ϴ.");
		return { "None", "0" };
	}
	front = (front + 1) % SIZE;
	Array <string> data = callQueue[front];
	callQueue[front] = { "None", "0" };
	return data;
}

Array <string> peek() {
	if (isQueueEmpty()) {
		println("ť ϴ.");
		return { "None", "0" };
	}
	return callQueue[(front + 1) % SIZE];
}

int calcTime() {
	int timeSum = 0;
	for (int i = (front + 1) % SIZE; i < (rear + 1) % SIZE; i++)
		timeSum += stoi(callQueue[i][1]);
	return timeSum;
}

int main() {
	for (int i = 0; i < SIZE; i++)
		callQueue.push_back({ "None", "0" });

	Array <Array <string>> waitCall = { {"", "9"}, {"", "3"}, {"ȯ", "4"}, {"ȯ", "4"}, {"", "3"} };

	for (int i = 0; i < len(waitCall); i++) {
		Array <string> call = waitCall[i];
		int waitTime = calcTime();
		println("  ð " + to_string(waitTime) + "Դϴ.");
		print("   -->");
		printArray2(callQueue);
		print(endl);
		enQueue(call);
	}

	print("   -->");
	printArray2(callQueue);
	println("α׷ !");
}